﻿#region Using Statements

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using MilwormsGameData;

#endregion

namespace MilwormsGameContentPipeline
{
    [ContentTypeWriter]
    public class WorldEntryWriter<T> : MilwormsGameWriter<WorldEntry<T>>
        where T : ContentObject
    {
        MapEntryWriter<T> mapEntryWriter = null;

        protected override void Initialize(ContentCompiler compiler)
        {
            mapEntryWriter = compiler.GetTypeWriter(typeof(MapEntry<T>))
                as MapEntryWriter<T>;

            base.Initialize(compiler);
        }

        protected override void Write(ContentWriter output, WorldEntry<T> value)
        {
            output.WriteRawObject<MapEntry<T>>(value as MapEntry<T>,
                mapEntryWriter);

            output.Write(value.MapContentName);
        }

        public override string GetRuntimeType(TargetPlatform targetPlatform)
        {
            //   return base.GetRuntimeType(targetPlatform);
            return typeof(MilwormsGameData.MapEntry<T>).AssemblyQualifiedName;
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            //return base.GetRuntimeReader(targetPlatform);
            return typeof(MilwormsGameData.MapEntry<T>.MapEntryReader).AssemblyQualifiedName;
        }
    }
}
